package org.anyin.gitee.cloud.center.auth.controller;

import cn.hutool.core.date.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.anyin.gitee.cloud.center.auth.controller.form.LoginForm;
import org.anyin.gitee.cloud.center.auth.convert.LoginConvert;
import org.anyin.gitee.cloud.center.auth.extension.dto.LoginUserDTO;
import org.anyin.gitee.cloud.center.auth.service.LoginService;
import org.anyin.gitee.cloud.center.auth.service.dto.LoginDTO;
import org.anyin.gitee.cloud.center.upms.api.resp.SysUserResp;
import org.anyin.gitee.cloud.lib.core.cache.CacheTemplate;
import org.anyin.gitee.cloud.lib.core.web.ApiResponse;
import org.anyin.gitee.cloud.lib.core.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.Set;

@RestController
@RequestMapping
public class LoginController extends BaseController {

    @Autowired
    private LoginService loginService;
    @Autowired
    private LoginConvert loginConvert;

    @PostMapping("/login")
    public ApiResponse<LoginUserDTO> login(@RequestBody LoginForm form){
        LoginDTO param = loginConvert.getLoginDTO(form);
        LoginUserDTO user = loginService.login(param);
        return ApiResponse.success(user);
    }
}
